import VueRouter from "vue-router";
import Home from "./views/Home.vue";

// const originalPush : any = VueRouter.prototype.push
// VueRouter.prototype.push = function push(location: any, onResolve: any, onReject: any){
//     if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
//     return originalPush.call(this, location).catch((err: any) => err)
// }

export default new VueRouter({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    { path: "/", redirect: "/trading" },
    // {
    //   path: '/',
    //   component: Home,
    //   meta: {
    //     iconCls: 'fa fa-home fa-fw',
    //     operations: '首页',
    //     leaf: true,
    //   },
    //   children: [
    //     {
    //       path: '/main',
    //       name: "首页",
    //       component: (resolve: any) => require(['./views/main/Index.vue'], resolve),
    //       meta: {
    //         operations: "首页",
    //       }
    //     }
    //   ]
    // },
    {
      path: "/",
      component: Home,
      name: "交易大厅",
      meta: {
        iconCls: "el-icon-s-grid",
        // operations: '交易大厅',
        // requireAuth: true,
      },
      children: [
        {
          path: "/trading",
          component: (resolve: any) =>
            require(["./views/trading/index.vue"], resolve),
          name: "交易大厅",
          // meta: {
          //   requireAuth: true,
          // }
        },
        {
          path: "/dataCompare",
          component: (resolve: any) =>
            require(["./views/trading/dataCompare.vue"], resolve),
          name: "交易数据比较",
          // meta: {
          //   requireAuth: true,
          // }
        },
        {
          path: "/blockDetail",
          component: (resolve: any) =>
            require(["./views/trading/blockDetail.vue"], resolve),
          name: "区块详情",
          // meta: {
          //   requireAuth: true,
          // }
        },
      ],
    },
    {
      path: "/",
      component: Home,
      name: "我的报价",
      meta: {
        iconCls: "el-icon-s-data",
        operations: "我的报价",
        // requireAuth: true,
        isAdmin: 2, // 非电网角色
      },
      children: [
        {
          path: "/myOffer",
          component: (resolve: any) =>
            require(["./views/myOffer/index.vue"], resolve),
          name: "我的报价",
          // meta: {
          //   requireAuth: true
          // }
        },
        {
          path: "/priceDetail",
          component: (resolve: any) =>
            require(["./views/myOffer/priceDetail.vue"], resolve),
          name: "报价单详情",
          // meta: {
          //   requireAuth: true
          // }
        },
      ],
    },
    {
      path: "/",
      component: Home,
      name: "我的订单",
      meta: {
        iconCls: "el-icon-coin",
        operations: "我的订单",
        isAdmin: 2, // 非电网角色
      },
      children: [
        {
          path: "/myOrder",
          component: (resolve: any) =>
            require(["./views/myOrder/index.vue"], resolve),
          name: "我的订单",
          // meta: {
          //   requireAuth: true
          // }
        },
        {
          path: "/orderDetail",
          component: (resolve: any) =>
            require(["./views/myOrder/orderDetail.vue"], resolve),
          name: "订单详情",
          // meta: {
          //   requireAuth: true
          // }
        },
      ],
    },
    {
      path: "/",
      component: Home,
      name: "系统管理",
      meta: {
        iconCls: "el-icon-s-tools",
        operations: "系统管理",
        isAdmin: 1,
      },
      children: [
        {
          path: "/system",
          component: (resolve: any) =>
            require(["./views/system/index.vue"], resolve),
          name: "系统管理",
          // meta: {
          //   requireAuth: true
          // }
        },
      ],
    },
    {
      path: "/",
      component: Home,
      meta: {
        iconCls: "el-icon-s-grid",
        hidden: true
      },
      children: [
        {
          path: "/accountInformation",
          name: "账号信息",
          meta: {
            hidden: true
          },
          component: (resolve: any) =>
            require(["./views/system/accountInformation.vue"], resolve)
        }
      ],
    },
    {
      path: "/login",
      component: (resolve: any) => require(["./views/Login.vue"], resolve),
      name: "登录",
      meta: {
        hidden: true,
      },
    },
    {
      path: "*",
      component: (resolve: any) => require(["./views/404.vue"], resolve),
      name: "404",
      meta: {
        leaf: false,
        hidden: true,
      },
    },
  ],
});
